<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <div id="div_body" >
	<script src="${pageContext.request.contextPath}/erp/js/showImg.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/geo.js" type="text/javascript"></script>
	<form id="add_hq_from" action="${pageContext.request.contextPath}/note/charge" method="post" class="pageForm required-validate"
  		 onsubmit="return iframeCallback(this,navTabAjaxDone);" enctype="multipart/form-data">
	
		<div layouth="56" class="pageFormContent" style="height: 186px; overflow: auto;">
			<p>
				<label>总部编码：</label>
				<input type="text" size="15" class="textInput" readonly="readonly" name="hqId" id="hqId" value="${hqBaseInfoTO.hqId }"/>
			</p>
			<p>
				<label>总部名称：</label>
				<input type="text" size="15" class="textInput" readonly="readonly" name="hqName" id="hqName" value="${hqBaseInfoTO.hqName }"/>
			</p>
			<p>
				<label>充值条数：</label>
				<input type="number" size="15" class="required textInput" name="addCnt" id="addCnt" />
			</p>
			<p>
				<label>充值金额：</label>
				<input type="text" size="15" class="required textInput" name="amount" id="amount"/>
			</p>
			
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="from_submit()">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button class="close" type="button">取消</button></div></div>
				</li>
			</ul>
		</div>
		
	</form>
	<script>
	 /*页面加载就开始执行js*/
    	var from = $("#add_hq_from");
	    $(document).ready(function () {
	    	$.post("${pageContext.request.contextPath}/address/listProvinces", 
   			   function(data){
	    		 if(data.code == 200){
	                    var result = "<option value=''>选择省份</option>";
	                    $.each(data.list,function(n,value){
	                        result +="<option value='"+value.provinceId+"'>"+value.province+"</option>";
	                    });
	                    $(from).find("#provinceId").html('');
	                    $(from).find("#provinceId").append(result);
	                }
   			   });
	    	
	    	 $(from).find("#provinceId").change(function(){list_city()});
	    	 $(from).find("#cityId").change(function () {
	    		 $(from).find("#city").val( $(from).find("#cityId").find("option:selected").text());
// 	        	$.post("${pageContext.request.contextPath}/address/listAreas",{cityId:$("#cityId").val()}, 
//        			   function(data){
//     	    		 if(data.code == 200){
//     	                    var result = "<option>选择区域</option>";
//     	                    $.each(data.list,function(n,value){
//     	                    	console.debug(value.areaId);
//     	                    	result +="<option value='"+value.areaId+"'>"+value.area+"</option>";
//     	                    });
//    				    		 $("#areaId").html('');
// 	                   		 $("#areaId").append(result);
//     	                }
//        			   });
	        });
	    });
	function from_submit(){  
		var provinceId =  $(from).find("#provinceId").val();
		var cityId =  $(from).find("#cityId").val();
		if(provinceId == ""){
			alertMsg.error("省份不能为空");
			return false;
		}
		if(cityId == ""){
			alertMsg.error("城市不能为空");
			return false;
		}
		$(from).submit(); 
	    
	} ;
	function list_city() {
		
   	 	$(from).find("#province").val($(from).find("#provinceId").find("option:selected").text());
		var provinceId =  $(from).find("#provinceId").val()
        var result = "<option value=''>选择城市</option>";
		if(provinceId == ""){
			 $(from).find("#cityId").html('');
			 $(from).find("#cityId").append(result);
			 return;
		}
   		$.post("${pageContext.request.contextPath}/address/listCity",{provinceId:$(from).find("#provinceId").val()}, 
			   function(data){
   		 if(data.code == 200){
                 $.each(data.list,function(n,value){
                 	 result +="<option value='"+value.cityId+"'>"+value.city+"</option>";
                 });
                 $(from).find("#cityId").html('');
                 $(from).find("#cityId").append(result);
             }
	   });
   }
	
		 
</script>
</div>